package com.longqian.huaduso.controller;

import com.longqian.huaduso.common.BaseResponse;
import com.longqian.huaduso.common.ResultUtils;
import com.longqian.huaduso.manager.SearchFacade;
import com.longqian.huaduso.model.dto.search.SearchRequest;
import com.longqian.huaduso.model.vo.SearchVO;
import com.longqian.huaduso.service.PictureService;
import com.longqian.huaduso.service.PostService;
import com.longqian.huaduso.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 搜索接口
 */
@RestController
@RequestMapping("/search")
@Slf4j
public class SearchController {
//    暂时用不到
//    @Resource
//    private UserService userService;
//    @Resource
//    private PostService postService;
//    @Resource
//    private PictureService pictureService;
    @Resource
    private SearchFacade searchFacade;

    @PostMapping("/all")
    public BaseResponse<SearchVO> searchAll(@RequestBody SearchRequest searchRequest, HttpServletRequest request) {
        return ResultUtils.success(searchFacade.searchAll(searchRequest,request));
    }

}
//watcheffect是自动更新数据，处理副作用。而响应式变量是自动更新视图，涉及到数据部分貌似不会立即更新
//watcheffect的例子
//watchEffect(() => {
//doubledCount.value = count.value * 2; // 自动追踪 count 的变化
//        });
//        const count = ref(0);
//ref，响应式变量的例子
// 在模板中使用 count
// <div>{{ count }}</div>
// 当 count 的值改变时，视图会自动更新

//适配器模式：定制统一的数据源接入规范